﻿using System;
using System.Data;
using System.Collections.Generic;
using XF.Common;
using XF.Model;
using XF.DALFactory;
using XF.IDAL;
using System.Collections;

namespace XF.BLL
{
	/// <summary>
	/// Bill_STOItems
	/// </summary>
	public partial class Bill_STOItems
	{
		private readonly IBill_STOItems dal = DataAccess.CreateBill_STOItems();
		public Bill_STOItems()
		{ }
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Id)
		{
			return dal.Exists(Id);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(XF.Model.Bill_STOItems model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(XF.Model.Bill_STOItems model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{

			return dal.Delete(Id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string Idlist)
		{
			return dal.DeleteList(Idlist);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XF.Model.Bill_STOItems GetModel(int Id)
		{

			return dal.GetModel(Id);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top, string strWhere, string filedOrder)
		{
			return dal.GetList(Top, strWhere, filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XF.Model.Bill_STOItems> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<XF.Model.Bill_STOItems> DataTableToList(DataTable dt)
		{
			List<XF.Model.Bill_STOItems> modelList = new List<XF.Model.Bill_STOItems>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				XF.Model.Bill_STOItems model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = dal.DataRowToModel(dt.Rows[n]);
					if (model != null)
					{
						modelList.Add(model);
					}
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
		//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  BasicMethod
		#region  ExtensionMethod
		// <summary>
		/// 获取分页数据
		/// </summary>
		/// <param name="strWhere"></param>
		/// <param name="strOrder"></param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <param name="count"></param>
		/// <returns></returns>
		public DataTable GetListByPage(string strWhere, string strOrder, int pageIndex, int pageSize, ref int count)
		{
			return dal.GetListByPage(strWhere, strOrder, pageIndex, pageSize, ref count);
		}

		public DataTable GetDetailListByPage(string strWhere, string strOrder, int pageIndex, int pageSize, ref int count)
		{
			return dal.GetDetailListByPage(strWhere, strOrder, pageIndex, pageSize, ref count);
		}
		public DictionaryEntry GetAddSql(XF.Model.Bill_STOItems model)
        {
			return dal.GetAddSql(model);
        }

		public DictionaryEntry GetUpdateSql(XF.Model.Bill_STOItems model)
        {
			return dal.GetUpdateSql(model);
        }

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetDetailList(string strWhere)
		{
			return dal.GetDetailList(strWhere);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public XF.Model.Bill_STOItems GetDetailModel(int Id)
        {
			return dal.GetDetailModel(Id);
        }

		/// <summary>
		/// 获取对账单
		/// </summary>
		/// <param name="strWhere"></param>
		/// <param name="strHaving"></param>
		/// <returns></returns>
		public DataSet GetSaleStatement(string strWhere, string strHaving)
		{
			return dal.GetSaleStatement(strWhere,strHaving);
		}

		/// <summary>
		/// 获取历史订单
		/// </summary>
		/// <param name="strWhere"></param>
		/// <returns></returns>
		public DataSet GetHistoryList(string strWhere)
        {
			return dal.GetHistoryList(strWhere);
        }

		/// <summary>
		/// 批量取消
		/// </summary>
		public bool CancelList(string Idlist)
		{
			return dal.CancelList(Idlist);
		}

		/// <summary>
		/// 批量恢复
		/// </summary>
		public bool RecoveryList(string Idlist)
		{
			return dal.RecoveryList(Idlist);
		}

		/// <summary>
		/// 批量完成
		/// </summary>
		public bool CompleteList(string Idlist)
        {
			return dal.CompleteList(Idlist);
        }

		/// <summary>
		/// 保存订单码
		/// </summary>
		public bool SaveItemCode(int id, string itemCode)
        {
			return dal.SaveItemCode(id, itemCode);
        }
		#endregion  ExtensionMethod
	}
}

